package com.dynamixsoftware.printershare.ipp;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;

public class IppMessage
{
  public static short OP_GET_JOBS = 10;
  public static short OP_GET_JOB_ATTRIBUTES;
  public static short OP_GET_PRINTER_ATTRIBUTES = 11;
  public static short OP_GET_PRINTER_SUPPORTED_VALUES = 21;
  public static short OP_PRINT_JOB = 2;
  public static short OP_VALIDATE_JOB = 4;
  private static int last_sid;
  public short code;
  public Vector<IppAttribute> job_attributes;
  public Vector<IppAttribute> operation_attributes;
  public Vector<IppAttribute> printer_attributes;
  public int sid;
  public Vector<IppAttribute> unsupported_attributes;
  public short version;
  
  static
  {
    OP_GET_JOB_ATTRIBUTES = 9;
  }
  
  IppMessage() {}
  
  public IppMessage(short paramShort)
  {
    this.version = 257;
    this.code = paramShort;
    int i = 1 + last_sid;
    last_sid = i;
    this.sid = i;
    this.operation_attributes = new Vector();
    this.job_attributes = new Vector();
    this.printer_attributes = new Vector();
    this.unsupported_attributes = new Vector();
  }
  void readFromStream(InputStream var1) throws IOException {
      DataInputStream var2 = new DataInputStream(var1);
      this.version = var2.readShort();
      this.code = var2.readShort();
      this.sid = var2.readInt();
      this.operation_attributes = new Vector();
      this.job_attributes = new Vector();
      this.printer_attributes = new Vector();
      this.unsupported_attributes = new Vector();
      Vector var3 = null;

      while(true) {
         while(true) {
            byte var4 = var2.readByte();
            if((var4 & 240) == 0) {
               if(var4 == 1) {
                  var3 = this.operation_attributes;
               } else if(var4 == 2) {
                  var3 = this.job_attributes;
               } else {
                  if(var4 == 3) {
                     return;
                  }

                  if(var4 == 4) {
                     var3 = this.printer_attributes;
                  } else if(var4 == 5) {
                     var3 = this.unsupported_attributes;
                  } else {
                     var3 = null;
                  }
               }
            } else {
               IppAttribute var5 = new IppAttribute(var4);
               var5.readFromStream(var2);
               if(var3 != null) {
                  var3.add(var5);
               }
            }
         }
      }
   }

//  void readFromStream(InputStream paramInputStream)
//    throws IOException
//  {
//    DataInputStream localDataInputStream = new DataInputStream(paramInputStream);
//    this.version = localDataInputStream.readShort();
//    this.code = localDataInputStream.readShort();
//    this.sid = localDataInputStream.readInt();
//    this.operation_attributes = new Vector();
//    this.job_attributes = new Vector();
//    this.printer_attributes = new Vector();
//    this.unsupported_attributes = new Vector();
//    Vector localVector = null;
//    for (;;)
//    {
//      int i = localDataInputStream.readByte();
//      if ((i & 0xF0) == 0)
//      {
//        if (i == 1)
//        {
//          localVector = this.operation_attributes;
//        }
//        else if (i == 2)
//        {
//          localVector = this.job_attributes;
//        }
//        else
//        {
//          if (i == 3) {
//            return;
//          }
//          if (i == 4) {
//            localVector = this.printer_attributes;
//          } else if (i == 5) {
//            localVector = this.unsupported_attributes;
//          } else {
//            localVector = null;
//          }
//        }
//      }
//      else
//      {
//        IppAttribute localIppAttribute = new IppAttribute((byte)i);
//        localIppAttribute.readFromStream(localDataInputStream);
//        if (localVector != null) {
//          localVector.add(localIppAttribute);
//        }
//      }
//    }
//  }
  
  void writeToStream(OutputStream paramOutputStream)
    throws IOException
  {
    DataOutputStream localDataOutputStream = new DataOutputStream(paramOutputStream);
    localDataOutputStream.writeShort(this.version);
    localDataOutputStream.writeShort(this.code);
    localDataOutputStream.writeInt(this.sid);
    if (this.operation_attributes.size() > 0)
    {
      localDataOutputStream.writeByte(1);
      for (int m = 0; m < this.operation_attributes.size(); m++)
      {
        IppAttribute localIppAttribute4 = (IppAttribute)this.operation_attributes.get(m);
        localDataOutputStream.writeByte(localIppAttribute4.tag);
        localIppAttribute4.writeToStream(localDataOutputStream);
      }
    }
    if (this.job_attributes.size() > 0)
    {
      localDataOutputStream.writeByte(2);
      for (int k = 0; k < this.job_attributes.size(); k++)
      {
        IppAttribute localIppAttribute3 = (IppAttribute)this.job_attributes.get(k);
        localDataOutputStream.writeByte(localIppAttribute3.tag);
        localIppAttribute3.writeToStream(localDataOutputStream);
      }
    }
    if (this.printer_attributes.size() > 0)
    {
      localDataOutputStream.writeByte(4);
      for (int j = 0; j < this.printer_attributes.size(); j++)
      {
        IppAttribute localIppAttribute2 = (IppAttribute)this.printer_attributes.get(j);
        localDataOutputStream.writeByte(localIppAttribute2.tag);
        localIppAttribute2.writeToStream(localDataOutputStream);
      }
    }
    if (this.unsupported_attributes.size() > 0)
    {
      localDataOutputStream.writeByte(5);
      for (int i = 0; i < this.unsupported_attributes.size(); i++)
      {
        IppAttribute localIppAttribute1 = (IppAttribute)this.unsupported_attributes.get(i);
        localDataOutputStream.writeByte(localIppAttribute1.tag);
        localIppAttribute1.writeToStream(localDataOutputStream);
      }
    }
    localDataOutputStream.writeByte(3);
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.ipp.IppMessage
 * JD-Core Version:    0.7.0.1
 */